from django.core.files.storage import Storage
from django.conf import settings


class FdfsStorage(Storage):
    def open(self, name, mode='rb'): # 用于打开文件
        pass

    def save(self, name, content, max_length=None): # 用于保存文件
        pass

    def url(self, name):  # 读取图片地址
        """
        返回name所指文件的绝对URL
        :param name: 要读取文件的引用:group1/M00/00/00/wKhnnlxw_gmAcoWmAAEXU5wmjPs35.jpeg
        :return: http://192.168.103.158:8888/group1/M00/00/00/wKhnnlxw_gmAcoWmAAEXU5wmjPs35.jpeg
        return 'http://192.168.103.158:8888/' + name
        return 'http://image.meiduo.site:8888/' + name
        """
        return settings.FDFS_URL + name

